import myAxios from "../index";

export default {
  // 查询所有菜单
  list: () =>
    myAxios<Result<SysMenu[]>>({
      url: "/admin/system/sysMenu/list",
      method: "get",
    }),

  // 根据ID查询菜单
  getById: (id: number) =>
    myAxios<Result<SysMenu>>({
      url: `/admin/system/sysMenu/${id}`,
      method: "get",
    }),

  // 新增菜单
  save: (data: SysMenu) =>
    myAxios<Result<void>>({
      url: "/admin/system/sysMenu",
      method: "post",
      data,
    }),

  // 更新菜单
  update: (data: SysMenu) =>
    myAxios<Result<void>>({
      url: "/admin/system/sysMenu",
      method: "put",
      data,
    }),

  // 分页查询菜单
  page: (data: SysMenu) =>
    myAxios<Result<PageResult<SysMenu>>>({
      url: "/admin/system/sysMenu/page",
      method: "post",
      data,
    }),

  // 删除菜单
  delete: (id: number) =>
    myAxios<Result<void>>({
      url: `/admin/system/sysMenu/${id}`,
      method: "delete",
    }),

  // 批量删除菜单
  batchDelete: (ids: number[]) =>
    myAxios<Result<void>>({
      url: "/admin/system/sysMenu/batchDelete",
      method: "post",
      data: ids,
    }),
};
